package com.szu.subject.ui.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.szu.subject.domains.Address;
import com.szu.subject.domains.ClassTime;
import com.szu.subject.domains.College;
import com.szu.subject.domains.Comment;
import com.szu.subject.domains.Course;
import com.szu.subject.domains.Major;
import com.szu.subject.domains.Student;
import com.szu.subject.domains.StudentClass;
import com.szu.subject.domains.User;
import com.szu.subject.ui.service.AddressService;
import com.szu.subject.ui.service.CollegeService;
import com.szu.subject.ui.service.CommentService;
import com.szu.subject.ui.service.CourseService;
import com.szu.subject.ui.service.MajorService;
import com.szu.subject.ui.service.SelectionService;
import com.szu.subject.ui.service.StudentClassService;
import com.szu.subject.ui.service.StudentService;
import com.szu.subject.ui.service.UserService;

@RestController
@RequestMapping("admin")
@PreAuthorize("admin")
public class AdminController {

	@Autowired
	private CourseService courseService;
	
	@Autowired
	private StudentService studentService;
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private CollegeService collegeService;
	
	@Autowired
	private CommentService commentService;
	
	@Autowired
	private SelectionService selectionService;
	
	@Autowired
	private StudentClassService studentClassService;
	
	@Autowired
	private MajorService majorService;
	
	@Autowired
	private AddressService addressService;

	@RequestMapping("create-user")
	public User createUser(@RequestBody User user) {
		return userService.createUser(user);
	}

	@RequestMapping("delete-user")
	public int deleteUser(@RequestBody Long id) {
		return userService.deleteUser(id);
	}

	@RequestMapping("update-user")
	public User updateUser(@RequestBody User user) {
		return userService.updateUser(user);
	}

	@RequestMapping("batch-create-users")
	public List<User> createUser(@RequestBody List<User> users) {
		return userService.batchCreateUsers(users);
	}

	@RequestMapping("batch-delete-users")
	public int deleteUser(@RequestBody List<Long> ids) {
		return userService.batchDeleteUsers(ids);
	}

	@RequestMapping("batch-update-users")
	public List<User> updateUser(@RequestBody List<User> users) {
		return userService.batchUpdateUsers(users);
	}

	@RequestMapping("create-student")
	public Student createStudent(@RequestBody Student student) {
		return studentService.createStudent(student);
	}

	@RequestMapping("delete-student")
	public int deleteStudent(@RequestBody Long id) {
		return studentService.deleteStudent(id);
	}

	@RequestMapping("update-student")
	public Student updateStudent(@RequestBody Student student) {
		return studentService.updateStudent(student);
	}

	@RequestMapping("batch-create-students")
	public List<Student> createStudent(@RequestBody List<Student> students) {
		return studentService.batchCreateStudents(students);
	}

	@RequestMapping("batch-delete-students")
	public int deleteStudent(@RequestBody List<Long> ids) {
		return studentService.batchDeleteStudents(ids);
	}

	@RequestMapping("batch-update-students")
	public List<Student> updateStudent(@RequestBody List<Student> students) {
		return studentService.batchUpdateStudents(students);
	}

	@RequestMapping("create-studentClass")
	public StudentClass createStudentClass(@RequestBody StudentClass studentClass) {
		return studentClassService.createStudentClass(studentClass);
	}

	@RequestMapping("delete-studentClass")
	public int deleteStudentClass(@RequestBody Long id) {
		return studentClassService.deleteStudentClass(id);
	}

	@RequestMapping("update-studentClass")
	public StudentClass updateStudentClass(@RequestBody StudentClass studentClass) {
		return studentClassService.updateStudentClass(studentClass);
	}

	@RequestMapping("batch-create-studentClasses")
	public List<StudentClass> createStudentClass(@RequestBody List<StudentClass> studentClasses) {
		return studentClassService.batchCreateStudentClasses(studentClasses);
	}

	@RequestMapping("batch-delete-studentClasses")
	public int deleteStudentClass(@RequestBody List<Long> ids) {
		return studentClassService.batchDeleteStudentClasses(ids);
	}

	@RequestMapping("batch-update-studentClasses")
	public List<StudentClass> updateStudentClass(@RequestBody List<StudentClass> studentClasses) {
		return studentClassService.batchUpdateStudentClasses(studentClasses);
	}

	@RequestMapping("create-course")
	public Course createCourse(@RequestBody Course course) {
		return courseService.createCourse(course);
	}

	@RequestMapping("delete-course")
	public int deleteCourse(@RequestBody Long id) {
		return courseService.deleteCourse(id);
	}

	@RequestMapping("update-course")
	public Course updateCourse(@RequestBody Course course) {
		return courseService.updateCourse(course);
	}

	@RequestMapping("batch-create-courses")
	public List<Course> createCourse(@RequestBody List<Course> courses) {
		return courseService.batchCreateCourses(courses);
	}

	@RequestMapping("batch-delete-courses")
	public int deleteCourse(@RequestBody List<Long> ids) {
		return courseService.batchDeleteCourses(ids);
	}

	@RequestMapping("batch-update-courses")
	public List<Course> updateCourse(@RequestBody List<Course> courses) {
		return courseService.batchUpdateCourses(courses);
	}

	@RequestMapping("create-address")
	public Address createAddress(@RequestBody Address address) {
		return addressService.createAddress(address);
	}

	@RequestMapping("delete-address")
	public int deleteAddress(@RequestBody Long id) {
		return addressService.deleteAddress(id);
	}

	@RequestMapping("update-address")
	public Address updateAddress(@RequestBody Address address) {
		return addressService.updateAddress(address);
	}

	@RequestMapping("batch-create-addresses")
	public List<Address> createAddress(@RequestBody List<Address> addresses) {
		return addressService.batchCreateAddresses(addresses);
	}

	@RequestMapping("batch-delete-addresses")
	public int deleteAddress(@RequestBody List<Long> ids) {
		return addressService.batchDeleteAddresses(ids);
	}

	@RequestMapping("batch-update-addresses")
	public List<Address> updateAddress(@RequestBody List<Address> addresses) {
		return addressService.batchUpdateAddresses(addresses);
	}

	@RequestMapping("create-college")
	public College createCollege(@RequestBody College college) {
		return collegeService.createCollege(college);
	}

	@RequestMapping("delete-college")
	public int deleteCollege(@RequestBody Long id) {
		return collegeService.deleteCollege(id);
	}

	@RequestMapping("update-college")
	public College updateCollege(@RequestBody College college) {
		return collegeService.updateCollege(college);
	}

	@RequestMapping("batch-create-colleges")
	public List<College> createCollege(@RequestBody List<College> colleges) {
		return collegeService.batchCreateColleges(colleges);
	}

	@RequestMapping("batch-delete-colleges")
	public int deleteCollege(@RequestBody List<Long> ids) {
		return collegeService.batchDeleteColleges(ids);
	}

	@RequestMapping("batch-update-colleges")
	public List<College> updateCollege(@RequestBody List<College> colleges) {
		return collegeService.batchUpdateColleges(colleges);
	}

	@RequestMapping("create-comment")
	public Comment createComment(@RequestBody Comment comment) {
		return commentService.createComment(comment);
	}

	@RequestMapping("delete-comment")
	public int deleteComment(@RequestBody Long id) {
		return commentService.deleteComment(id);
	}

	@RequestMapping("update-comment")
	public Comment updateComment(@RequestBody Comment comment) {
		return commentService.updateComment(comment);
	}

	@RequestMapping("batch-create-comments")
	public List<Comment> createComment(@RequestBody List<Comment> comments) {
		return commentService.batchCreateComments(comments);
	}

	@RequestMapping("batch-delete-comments")
	public int deleteComment(@RequestBody List<Long> ids) {
		return commentService.batchDeleteComments(ids);
	}

	@RequestMapping("batch-update-comments")
	public List<Comment> updateComment(@RequestBody List<Comment> comments) {
		return commentService.batchUpdateComments(comments);
	}

	@RequestMapping("create-major")
	public Major createMajor(@RequestBody Major major) {
		return majorService.createMajor(major);
	}

	@RequestMapping("delete-major")
	public int deleteMajor(@RequestBody Long id) {
		return majorService.deleteMajor(id);
	}

	@RequestMapping("update-major")
	public Major updateMajor(@RequestBody Major major) {
		return majorService.updateMajor(major);
	}

	@RequestMapping("batch-create-majors")
	public List<Major> createMajor(@RequestBody List<Major> majors) {
		return majorService.batchCreateMajors(majors);
	}

	@RequestMapping("batch-delete-majors")
	public int deleteMajor(@RequestBody List<Long> ids) {
		return majorService.batchDeleteMajors(ids);
	}

	@RequestMapping("batch-update-majors")
	public List<Major> updateMajor(@RequestBody List<Major> majors) {
		return majorService.batchUpdateMajors(majors);
	}
}
